<template>
  <div>
    <el-card>
      <el-form ref="elForm" :model="formData" size="medium" label-width="134px" >
        <el-row>
          <el-col :span="8">
            <el-form-item label="填表人姓名" prop="formFillingMan" >
              <el-input v-model="formData.formFillingMan" clearable :style="{width: '100%'}" :disabled="b_disabled"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="填表人电话" prop="linkTel" >
              <el-input v-model="formData.linkTel" clearable :style="{width: '100%'}" :disabled="b_disabled"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="领导姓名" prop="leaderName" >
              <el-input v-model="formData.leaderName" clearable :style="{width: '100%'}" :disabled="b_disabled"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" prop="gender" >
              <el-input v-model="formData.gender" clearable :style="{width: '100%'}" :disabled="b_disabled"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="民族" prop="folk" >
              <el-select v-model="formData.folk" clearable :style="{width: '100%'}" :disabled="b_disabled">
                <el-option v-for="(item, index) in folkOptions" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="出生年月日" prop="birthDate" >
              <el-date-picker v-model="formData.birthDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                              :style="{width: '100%'}" clearable :disabled="b_disabled"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="政治面貌" prop="pol" >
              <el-select v-model="formData.pol" placeholder="政治面貌" clearable :style="{width: '100%'}" :disabled="b_disabled">
                <el-option v-for="(item, index) in polOptions" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="学历" prop="edu" >
              <el-select v-model="formData.edu" clearable :style="{width: '100%'}" :disabled="b_disabled">
                <el-option v-for="(item, index) in eduOptions" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="学位" prop="degree" >
              <el-input v-model="formData.degree" clearable :style="{width: '100%'}" :disabled="b_disabled"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="职务" prop="manageJob" >
              <el-select v-model="formData.manageJob" clearable :style="{width: '100%'}" :disabled="b_disabled">
                <el-option v-for="(item, index) in manageJobOptions" :key="index" :label="item.label"
                           :value="item.value" ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="职级" prop="title">
              <el-select v-model="formData.title" placeholder="职级" clearable :style="{width: '100%'}" :disabled="b_disabled">
                <el-option v-for="(item, index) in titleOptions" :key="index" :label="item.label"
                           :value="item.value"  ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="认职日期" prop="serDate" >
              <el-date-picker v-model="formData.serDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                              :style="{width: '100%'}" clearable :disabled="b_disabled"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="离职日期" prop="leaveDate" >
              <el-date-picker v-model="formData.leaveDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                              :style="{width: '100%'}" clearable :disabled="b_disabled"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="填表年份" prop="yearly" >
              <el-date-picker v-model="formData.yearly" type="year" format="yyyy" value-format="yyyy"
                              :style="{width: '100%'}" clearable :disabled="b_disabled"></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="备注" prop="memo" >
              <el-input
                type="formData.memo"
                :rows="2"
                placeholder="请输入内容"
                v-model="formData.memo" :disabled="b_disabled">
              </el-input>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-form-item size="large" v-if="display">
            <el-button type="primary" @click="managesubmit">提交</el-button>
            <el-button @click="$router.go(-1)">返回</el-button>
          </el-form-item>
          <el-form-item size="large" v-else  >
            <el-button type="primary" @click="update">修改</el-button>
            <el-button @click="$router.go(-1)">返回</el-button>
          </el-form-item>
        </el-row>
      </el-form>
    </el-card>
  </div>
</template>

<script>
  import {post} from "@/utils/api";
  export default {
    props:{
      id:Number,
      display:Boolean,
      b_disabled:Boolean,
      su:Boolean,
    },
    data() {
      return {
        form:[],
        formData:{},
        folkOptions: [{
          "label": "汉",
          "value": "汉"
        }, {
          "label": "少数民族",
          "value": "少数民族"
        }],
        polOptions: [{
          "label": "中共党员",
          "value": "中共党员"
        }, {
          "label": "团员",
          "value": "团员"
        }, {
          "label": "民族党派",
          "value": "民族党派"
        }, {
          "label": "群众",
          "value": "群众"
        }],
        eduOptions: [{
          "label": "无学历",
          "value": "无学历"
        }, {
          "label": "初中",
          "value": "初中"
        }, {
          "label": "高中",
          "value": "高中"
        }, {
          "label": "中专",
          "value": "中专"
        }, {
          "label": "大专",
          "value": "大专"
        }, {
          "label": "本科",
          "value": "本科"
        }, {
          "label": "硕士",
          "value": "硕士"
        }, {
          "label": "博士",
          "value": "博士"
        }],
        manageJobOptions: [{
          "label": "所(局)长",
          "value": 1
        }, {
          "label": "党委(副)书记",
          "value": 2
        }, {
          "label": "副所(局)长",
          "value": 3
        }, {
          "label": "科室主任",
          "value": 4
        }, {
          "label": "科室副主任",
          "value": 5
        }, {
          "label": "无职称",
          "value": 6
        }],
        jobLevelOptions: [{
          "label": "无",
          "value": 0
        }, {
          "label": "省部级正职",
          "value": 1
        }, {
          "label": "省部级副职",
          "value": 2
        }, {
          "label": "厅局级正职",
          "value": 3
        }, {
          "label": "厅局级副职",
          "value": 4
        }, {
          "label": "县处级正职",
          "value": 5
        }, {
          "label": "县处级副职",
          "value": 6
        }, {
          "label": "乡科级正职",
          "value": 7
        }, {
          "label": "乡科级副职",
          "value": 8
        }, {
          "label": "科办员",
          "value": 9
        }],
        titleOptions: [{
          "label": "初级医师",
          "value": 1,
        }, {
          "label": "初级技师",
          "value": 2,
        }, {
          "label": "助理政工师",
          "value": 3,
        }, {
          "label": "助理工程师",
          "value": 4,
        }, {
          "label": "助理会计师",
          "value": 5,
        }, {
          "label": "研究实习员",
          "value": 6,
        }, {
          "label": "主管",
          "value": 7,
        }, {
          "label": "主治",
          "value": 8,
        }, {
          "label": "中级医师",
          "value": 9,
        }, {
          "label": "中级技师",
          "value": 10,
        }, {
          "label": "政工师",
          "value": 11,
        }, {
          "label": "馆员",
          "value": 12,
        }, {
          "label": "工程师",
          "value": 13,
        }, {
          "label": "会计师",
          "value": 14,
        }, {
          "label": "副主任医师",
          "value": 15,
        }, {
          "label": "副主任技师",
          "value": 16,
        }, {
          "label": "高级政工师",
          "value": 17,
        }, {
          "label": "高级会计师",
          "value": 18,
        }, {
          "label": "主任医师",
          "value": 19,
        }, {
          "label": "主任技师",
          "value": 20,
        }, {
          "label": "无职称",
          "value": 21,
        }, {
          "label": "未聘任专业技术职务",
          "value": 22,
        }, {
          "label": "不详",
          "value": 23,
        }],
      }
    },
    created() {
      if(this.id!=null){
        this.getbyid()
      }

    },
    methods: {
      async getbyid(){
        let res = await post("leader/getbyid",{id:this.id})
        console.log(res.title)
        if(res.title==1)
          res.title="初级医师";
        if(res.title==2)
          res.title="初级技师";
        if(res.title==3)
          res.title="助理政工师";
        if(res.title==4)
          res.title="助理工程师";
        if(res.title==5)
          res.title="助理会计师";
        if(res.title==6)
          res.title="研究实习员";
        if(res.title==7)
          res.title="主管";
        if(res.title==8)
          res.title="主治";
        if(res.title==9)
          res.title="中级医师";
        if(res.title==10)
          res.title="中级技师";
        if(res.title==11)
          res.title="政工师";
        if(res.title==12)
          res.title="馆员";
        if(res.title==13)
          res.title="工程师";
        if(res.title==14)
          res.title="会计师";
        if(res.title==15)
          res.title="副主任医师";
        if(res.title==16)
          res.title="副主任技师";
        if(res.title==17)
          res.title="高级政工师";
        if(res.title==18)
          res.title="高级会计师";
        if(res.title==19)
          res.title="主任医师";
        if(res.title==20)
          res.title="主任技师";
        if(res.title==21)
          res.title="无职称";
        if(res.title==22)
          res.title="未聘任专业技术职务";
        if(res.title==23)
          res.title="不详";
        this.formData =res
      },
      async managesubmit(){
        console.log(this.formData)
        if(this.id!=null){
          let res = await post("leader/byidupdate",{...this.formData})
        }else {
          let res = await post("leader/leaderadd",{...this.formData})
        }

      },
      update(){
        this.$router.push({name:"manageupdate",query:{id:this.id}})
      }
    }


  }
</script>
<style></style>
